import {Service} from "adajs";

class NewsService extends Service {
    defaultData() {
        return {
            isLoad: false,
            newsInfo: {
                age: 73,
                birth: "1945-01-01",
                birthday: "1945-01-01",
                birthdayBz: "f2d8b042-7dcc-47eb-ad9b-e8894a10bc22",
                id: "05822f58-0144-4a06-a380-022542a3ef4e",
                jg: "山东省",
                mz: "汉族",
                post: "山东电视台",
                raiseTreatment: "很适合护手霜",
                rdsj: "1945-01-01",
                retiredDate: "2018-12-01",
                retiredPost: "副地级",
                retiredType: "离休",
                rzsj: "1965-01-01",
                sex: "男",
                szdzb: "一支部",
                treatment: "正地级",
                treatmentDate: "2018-12-01",
                xl: "大学",
                xm: "测试002",
                xmOld: "测试002",
                zzmm: "中共党员"
            },
            id: ""
        };
    }

    onupdate(current, id) {
        if (id) {
            return this.context.request.post("/api/lgb/app/lgb/oldperson/details", {id}).then(({data}) => {
                current.id = id;
                current.isLoad = true;
                Object.assign(current.newsInfo, data);
            });
        }
    }
}

export default NewsService;